ukr_adm1, ukr_adm2, viina, viina_adm2_month, viina_locs,
file = "~/Desktop/clean_ukraine_data.RData"
)
setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse", "extrafont", "texreg", "sjlabelled", "kableExtra",
"ggmap","ggthemes", "sf")
ipak(packages)
##=============================================================================
## Main Manuscript: Figure 1
##=============================================================================
##-----------------
# clear environment
rm(list=ls())
options(stringsAsFactors = FALSE, scipen = 999)
# source("R/functions.R")
##--------
# Set seed
seed <- sample.int(.Machine$integer.max, 1)
set.seed(seed)
##-------------
# Load Packages
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse", "extrafont", "texreg", "sjlabelled", "kableExtra",
"ggmap","ggthemes", "sf")
ipak(packages)
##---------
# Load Data
setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
interviews <- dat1 %>%
group_by(adm2_en) %>%
count() %>%
rename(interviews = n)
viina_counts <- dat1 %>%
dplyr::select(adm2_en, viina_cum_adm2) %>%
distinct(adm2_en, .keep_all = TRUE)
ukr_adm2 <- left_join(ukr_adm2, interviews, by = "adm2_en")
rm(interviews)
ukr_adm2 <- left_join(ukr_adm2, viina_counts, by = "adm2_en") %>%
mutate(viina_cum_adm2 = ifelse(is.na(viina_cum_adm2), 0, viina_cum_adm2))
rm(viina_counts)
ggplot(data = ukr_adm2, aes(fill = viina_cum_adm2, label = interviews)) +
geom_sf() +
geom_sf(aes(fill = viina_cum_adm2)) +
geom_sf_text(aes(label = interviews), colour = "white", label.size = 0.5,
fun.geometry = sf::st_centroid) +
scale_fill_continuous(low = "lightgray", high = "grey10") +
labs(fill = "Cumulative Combat Events", label = "Interview Count") +
theme_void() +
theme(legend.position = "bottom", legend.direction = "horizontal")
ukr_adm2 <- ukr_adm2 %>%
select(-c(interviews, viina_cum_adm2))
View(ukr_adm2)
interviews <- dat2 %>%
group_by(adm2_en) %>%
count() %>%
rename(interviews = n)
viina_counts <- dat2 %>%
dplyr::select(adm2_en, viina_cum_adm2) %>%
distinct(adm2_en, .keep_all = TRUE)
ukr_adm2 <- ukr_adm2 %>%
dplyr::select(-c(interviews, viina_cum_adm2))
interviews <- dat2 %>%
group_by(adm2_en) %>%
count() %>%
rename(interviews = n)
View(interviews)
viina_counts <- dat2 %>%
dplyr::select(adm2_en, viina_cum_adm2) %>%
distinct(adm2_en, .keep_all = TRUE)
View(viina_counts)
ukr_adm2 <- left_join(ukr_adm2, interviews, by = "adm2_en") %>%
mutate(interviews = ifelse(is.na(interviews), 0, interviews))
rm(interviews)
ukr_adm2 <- left_join(ukr_adm2, viina_counts, by = "adm2_en") %>%
mutate(viina_cum_adm2 = ifelse(is.na(viina_cum_adm2), 0, viina_cum_adm2))
rm(viina_counts)
ggplot(data = ukr_adm2, aes(fill = viina_cum_adm2, label = interviews)) +
geom_sf() +
geom_sf(aes(fill = viina_cum_adm2)) +
geom_sf_text(aes(label = interviews), colour = "white",
fun.geometry = sf::st_centroid) +
scale_fill_continuous(low = "lightgray", high = "grey10") +
labs(fill = "Cumulative Combat Events", label = "Interview Count") +
theme_void() +
theme(legend.position = "bottom", legend.direction = "horizontal")
ukr_adm2 <- ukr_adm2 %>%
select(-c(interviews, viina_cum_adm2))
View(ukr_adm2)
View(ukr_adm2)
##=============================================================================
## Main Manuscript: Table 1
##=============================================================================
##-----------------
# clear environment
rm(list=ls())
options(stringsAsFactors = FALSE, scipen = 999)
# source("R/functions.R")
##--------
# Set seed
seed <- sample.int(.Machine$integer.max, 1)
set.seed(seed)
##-------------
# Load Packages
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse")
ipak(packages)
setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
dat %>%
dplyr::select(wave, save_lives, compromise, compromise_idx_full,
ukr_no_nato, rus_lang_schools) %>%
group_by(wave) %>%
summarise(across(everything(), list(mean = mean, sd = sd), na.rm = TRUE)) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "stat")
dat %>%
dplyr::select(wave, save_lives, compromise, compromise_idx_full,
ukr_no_nato, rus_lang_schools) %>%
group_by(wave) %>%
summarise_all(~ sum(is.na(.))) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "missing")
2000-386
2000-431
2007-431
dat %>%
dplyr::select(wave, save_lives, compromise, compromise_idx_full,
ukr_no_nato, rus_lang_schools) %>%
group_by(wave) %>%
summarise(across(everything(), list(mean = mean, sd = sd), na.rm = TRUE)) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "stat")
rm(list=ls())
options(stringsAsFactors = FALSE, scipen = 999)
# source("R/functions.R")
##--------
# Set seed
seed <- sample.int(.Machine$integer.max, 1)
set.seed(seed)
##-------------
# Load Packages
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse")
ipak(packages)
##---------
# Load data
setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
dat %>%
dplyr::select(wave, survival_mindset, frontline_b, ln_viina_two_months,
per_idx_invcov, fam_idx_invcov) %>%
group_by(wave) %>%
summarise(across(everything(), list(mean = mean, sd = sd), na.rm = TRUE)) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "stat")
dat %>%
dplyr::select(wave, survival_mindset, frontline_b, ln_viina_two_months,
per_idx_invcov, fam_idx_invcov) %>%
group_by(wave) %>%
summarise_all(~ sum(is.na(.))) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "missing")
2007-169
2007-136
2007-90
##=============================================================================
## Main Manuscript: Table 4
##=============================================================================
##-----------------
# clear environment
rm(list=ls())
options(stringsAsFactors = FALSE, scipen = 999)
# source("R/functions.R")
##--------
# Set seed
seed <- sample.int(.Machine$integer.max, 1)
set.seed(seed)
##-------------
# Load Packages
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse", "kableExtra", "broom", "hrbrthemes",
"modelsummary", "infer")
ipak(packages)
##---------
# Load data
setwd("~/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
dat %>%
filter(home_lang == 2) %>%
group_by(wave) %>%
count(home_lang)
dat %>%
filter(wave == 0 & home_lang == 2) %>% # n = 475
reframe(quantile(survival_mindset_z, na.rm = TRUE)) # 0.710
dat %>%
filter(wave == 1 & home_lang == 2) %>% # n = 376
reframe(quantile(survival_mindset_z, na.rm = TRUE)) # 0.710
rus_speak_1 <- dat %>%
filter(wave == 0 & home_lang == 2) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_speak_2 <- dat %>%
filter(wave == 1 & home_lang == 2) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
summary(rus_speak_1$survival_mindset_z)
rus_speak_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_speak_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_speak_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_speak_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_speak_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_speak_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_speak_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rm(rus_speak_1, rus_speak_2)
summary(rus_speak_1$survival_mindset_z)
rm(rus_speak_1, rus_speak_2)
dat %>%
filter(home_lang == 1) %>%
group_by(wave) %>%
count(home_lang)
##---------
# Load data
setwd("~/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
dat %>%
filter(home_lang == 1) %>%
group_by(wave) %>%
count(home_lang)
dat %>%  # n = 1,214
filter(wave == 0 & home_lang == 2 | home_lang == 3 | home_lang == 7) %>%
reframe(quantile(survival_mindset_z, na.rm = TRUE)) # 0.710
dat %>%  # n = 1,115
filter(wave == 1 & home_lang == 2 | home_lang == 3 | home_lang == 7) %>%
reframe(quantile(survival_mindset_z, na.rm = TRUE)) # 0.710
rus_bilingual_1 <- dat %>%
filter(wave == 0 & home_lang == 2 | home_lang == 3 | home_lang == 7) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_bilingual_2 <- dat %>%
filter(wave == 1 & home_lang == 2 | home_lang == 3 | home_lang == 7) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_bilingual_1 <- dat %>%
filter(wave == 0 & home_lang == 2 | home_lang == 3 | home_lang == 7) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_bilingual_2 <- dat %>%
filter(wave == 1 & home_lang == 2 | home_lang == 3 | home_lang == 7) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_bilingual_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_bilingual_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_bilingual_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_bilingual_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z  ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rm(rus_bilingual_1, rus_bilingual_2)
dat %>%
filter(ethnic == 2) %>%
group_by(wave) %>%
count(ethnic)
dat %>%
filter(wave == 0 & ethnic == 2) %>% # n = 49
reframe(quant75 = quantile(survival_mindset_z, na.rm = TRUE)) # 1.11
dat %>%
filter(wave == 1 & ethnic == 2) %>% # n = 49
reframe(quant75 = quantile(survival_mindset_z, na.rm = TRUE))
rus_eth_1 <- dat %>%
filter(wave == 0 & ethnic == 2) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 1.11, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_eth_2 <- dat %>%
filter(wave == 1 & ethnic == 2) %>%
mutate(survival_binary = ifelse(survival_mindset_z > 0.710, 1, 0)) %>%
mutate(survival_binary = factor(survival_binary,
labels = c("Low", "High"))) %>%
dplyr::select(id, compromise_idx_full_z, save_lives_z, survival_mindset_z,
survival_binary)
rus_eth_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_eth_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_eth_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_eth_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rus_eth_1 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
# Wave II -- Save Lives (z-std)
rus_eth_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = save_lives_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
# Wave II -- Compromise (z-std)
rus_eth_2 %>%
tidyr::drop_na(survival_binary) %>%
t_test(formula = compromise_idx_full_z ~ survival_binary,
alternative = "two-sided", order = c("Low", "High"))
rm(rus_eth_1, rus_eth_2)
rm(list = ls())
##=============================================================================
## Main Manuscript: Table 3
##=============================================================================
##-----------------
# clear environment
rm(list=ls())
options(stringsAsFactors = FALSE, scipen = 999)
# source("R/functions.R")
##--------
# Set seed
seed <- sample.int(.Machine$integer.max, 1)
set.seed(seed)
##-------------
# Load Packages
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse", "lme4", "sjPlot", "ordinal", "texreg", "hrbrthemes")
ipak(packages)
##---------
# Load Data
setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")
##-----
# Fit 1
str(dat$save_lives)
dat$save_lives <- factor(dat$save_lives)
fit1 <- clmm(save_lives ~ 1 + wave + survival_mindset + per_idx_invcov +
fam_idx_invcov + frontline_b + displaced + sex + rus_ethnic +
age + edu + job + ln_viina_two_months + finances +
(1 + wave + survival_mindset + per_idx_invcov + fam_idx_invcov |
adm1_en), data = dat)
sjPlot::tab_model(fit1)
#performance::icc(fit1)
sjPlot::plot_model(fit1)
AIC(logLik(fit1))
sjPlot::tab_model(fit1)
#performance::icc(fit1)
sjPlot::plot_model(fit1)
AIC(logLik(fit1))
sjPlot::tab_model(fit1)
sjPlot::tab_model(fit1)
get_model_data(fit1)
get_model_data(fit1)
get_model_data(fit1,
type = c("est", "std"))
fit2 <- glmer(compromise ~ 1 + wave + survival_mindset + per_idx_invcov +
fam_idx_invcov + frontline_b + ln_viina_two_months +
displaced + sex + rus_ethnic + age + edu + job + finances +
(1 + wave + survival_mindset + per_idx_invcov + fam_idx_invcov |
adm1_en),
data = dat,
family = binomial,
control = glmerControl(optimizer = "bobyqa"))
AIC(logLik(fit2))
sjPlot::tab_model(fit2)
summary(fit1)
summary(fit2)
summary(fit2)
#sjPlot::plot_model(fit2)
#performance::icc(fit2)
AIC(logLik(fit2))
tidy(fit2, effects = "fixed")
fit5 <- glmer(rus_lang_schools ~ 1 + wave + survival_mindset + per_idx_invcov +
fam_idx_invcov + frontline_b + ln_viina_two_months +
displaced + sex + rus_ethnic + age + edu + job + finances +
(1 + wave + survival_mindset + per_idx_invcov + fam_idx_invcov |
adm1_en),
data = dat,
family = binomial,
control = glmerControl(optimizer = "bobyqa"))
summary(fit5)
fit4 <- glmer(ukr_no_nato ~ 1 + wave + survival_mindset + per_idx_invcov +
fam_idx_invcov + frontline_b + ln_viina_two_months +
displaced + sex + rus_ethnic + age + edu + job + finances +
(1 + wave + survival_mindset + per_idx_invcov + fam_idx_invcov |
adm1_en),
data = dat,
family = binomial,
control = glmerControl(optimizer = "bobyqa"))
summary(fit4)
fit3 <- lmer(compromise_idx_terr_z ~ 1 + wave + survival_mindset +
per_idx_invcov + fam_idx_invcov + frontline_b +
ln_viina_two_months + displaced + rus_ethnic + sex + age +
edu + job + ln_viina_two_months + finances +
(1 + wave + survival_mindset + per_idx_invcov +
fam_idx_invcov | adm1_en), data = dat)
summary(fit3)
summary(fit3)
summary(fit1)
rm(fit2)
fit2 <- glmer(compromise ~ 1 + wave + survival_mindset + per_idx_invcov +
fam_idx_invcov + frontline_b + ln_viina_two_months +
displaced + sex + rus_ethnic + age + edu + job + finances +
(1 + wave + survival_mindset + per_idx_invcov + fam_idx_invcov |
adm1_en),
data = dat,
family = binomial,
control = glmerControl(optimizer = "bobyqa"))
summary(fit2)
setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("tidyverse")
ipak(packages)
load("clean_ukraine_data.RData")
dat %>%
dplyr::select(wave, save_lives, compromise, compromise_idx_full,
ukr_no_nato, rus_lang_schools) %>%
group_by(wave) %>%
summarise(across(everything(), list(mean = mean, sd = sd), na.rm = TRUE)) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "stat")
dat %>%
dplyr::select(wave, save_lives, compromise, compromise_idx_full,
ukr_no_nato, rus_lang_schools) %>%
group_by(wave) %>%
summarise_all(~ sum(is.na(.))) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "missing")
2007-431
dat %>%
dplyr::select(wave, survival_mindset, frontline_b, ln_viina_two_months,
per_idx_invcov, fam_idx_invcov) %>%
group_by(wave) %>%
summarise_all(~ sum(is.na(.))) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "missing")
2007-169
2007-90
2007-136
dat %>%
dplyr::select(wave, survival_mindset, frontline_b, ln_viina_two_months,
per_idx_invcov, fam_idx_invcov) %>%
group_by(wave) %>%
summarise(across(everything(), list(mean = mean, sd = sd), na.rm = TRUE)) %>%
pivot_longer(cols = -wave, names_to = "variable", values_to = "stat")
